<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.jdbct;</#if>

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.rowset.SqlRowSet;
import org.springframework.stereotype.Repository;
import zucc.kinect.page.EquipRedPageTime;
import zucc.kinect.page.EquipRedPageTimeYuan;
import zucc.kinect.util.DecimalUtil;
import zucc.kinect.util.StrUtil;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Slf4j
@Repository
public class ${classInfo.className}JdbcT {

private JdbcTemplate jdbcTemplate;

@Autowired
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}


String l(Object object) {
return StrUtil.like(object);
}

public List<Map<String, Object>>  list(${classInfo.className} ${classInfo.className?uncap_first}, Integer comId) {


    String sqlStr = "";
    if (comId != null) {
    sqlStr += "  and company_id = ?";

    }

    <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
        <#list classInfo.fieldList as fieldItem >
            if (${classInfo.className?uncap_first}.get${fieldItem.fieldName?cap_first}() != null) {
            sqlStr += " and ${classInfo.originTableName}.${fieldItem.columnName} like " + l(${classInfo.className?uncap_first}.get${fieldItem.fieldName?cap_first}());
            }
        </#list>
    </#if>


    int pageIndex = equipRedPageTimeYuan.getPageIndex();
    int pageSize = equipRedPageTimeYuan.getPageSize();

    String startTime = equipRedPageTimeYuan.getStartTime();
    String endTime = equipRedPageTimeYuan.getEndTime();
    if (startTime != null && endTime != null) {
    sqlStr += " and date(change_date)>= " + StrUtil.quotation(startTime);
    sqlStr += " and date(change_date)<= " + StrUtil.quotation(endTime);
    }

    List<Map<String, Object>> maps = jdbcTemplate.queryForList(sqlStr);
    return maps;


        }
        }
